﻿<UserControl x:Class="Axiom.CodeManifold.WPF.Views.ServicManifoldView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:componentmodel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
			 xmlns:mvvm="clr-namespace:Axiom.CodeManifold.WPF.ViewModels"
			 xmlns:sampledata="clr-namespace:Axiom.CodeManifold.WPF.SampleData"
			 xmlns:converters="clr-namespace:Axiom.CodeManifold.WPF.Converters"
             d:DataContext="{Binding Source={StaticResource SampleData}}"
             mc:Ignorable="d" 
             Loaded="OnLoaded"
			 FontSize="10"
			 FontFamily="Calibri"
             d:DesignHeight="550" d:DesignWidth="860">

	<UserControl.Resources>
		<ResourceDictionary>
			<mvvm:ServiceManifoldViewModel x:Key="Model"/>
			<sampledata:ServiceManifoldSampleData x:Key="SampleData"/>
			<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
			<converters:BoolToRedOrGreenImage x:Key="BoolToRedOrGreenImage"/>
			<converters:ObjectRefToRedOrGreenImage x:Key="ObjectRefToRedOrGreenImage"/>
			<converters:SplitPascalCamelCaseConverter x:Key="SplitPascalCase"/>
			<Style TargetType="ListViewItem">
				<Style.Resources>
					<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
				</Style.Resources>
			</Style>
			<CollectionViewSource x:Key="MethodItemsSource" Source="{Binding ServiceMethods}">
				<CollectionViewSource.SortDescriptions>
					<componentmodel:SortDescription PropertyName="Name"/>
				</CollectionViewSource.SortDescriptions>
				<CollectionViewSource.GroupDescriptions>
					<PropertyGroupDescription PropertyName="Subject"/>
				</CollectionViewSource.GroupDescriptions>
			</CollectionViewSource>
			<CollectionViewSource x:Key="RepositoryItemsSource" Source="{Binding SelectedServiceInterface.Repositories}">
			</CollectionViewSource>
		</ResourceDictionary>
	</UserControl.Resources>

	<UserControl.DataContext>
		<Binding Source="{StaticResource Model}"/>
	</UserControl.DataContext>

	<Grid>
		<Grid.Background>
			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
				<GradientStop Color="WhiteSmoke"/>
				<GradientStop Color="#FFDBDBDB" Offset="1"/>
			</LinearGradientBrush>
		</Grid.Background>
		<Grid.RowDefinitions>
			<RowDefinition Height="auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" MinWidth="150"/>
			<ColumnDefinition Width="200" MinWidth="100"/>
		</Grid.ColumnDefinitions>
		<ToolBarTray Background="White" Grid.ColumnSpan="2">
			<ToolBar Band="1" BandIndex="1" ToolBarTray.IsLocked="True" Loaded="OnToolBarLoaded">
				<Button Click="OnLaunchSolutions" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Launch Solutions" Height="20" Visibility="{Binding IsDisconnected, Converter={StaticResource BooleanToVisibilityConverter}}">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/visual.studio.png" />
				</Button>
				<Button Click="OnNew" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="New" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/new.png" />
				</Button>
				<Button Click="OnUndo" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Undo" Height="25" Visibility="{Binding Settings.ShouldCloseUndoContext, Converter={StaticResource BooleanToVisibilityConverter}}">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/undo.png" />
				</Button>
				<Button Click="OnSave" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Add/Update Method" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/code.png" />
				</Button>
				<Button Click="OnRefresh" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Refresh" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/project.working.gif" />
				</Button>
			</ToolBar>
			<ToolBar Band="1" BandIndex="1" ToolBarTray.IsLocked="True" Loaded="OnToolBarLoaded">
				<Button Click="OnSortMembers" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Sort Document Elements" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/application.png" />
				</Button>
			</ToolBar>
		</ToolBarTray>
		<TabControl Grid.Row="1" TabStripPlacement="Bottom" Background="{x:Null}">
			<TabItem Header="service manager">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="*"/>
					</Grid.RowDefinitions>
					<ScrollViewer Margin="4" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
						<StackPanel>
							<StackPanel.Resources>
								<Style TargetType="TextBox">
									<Setter Property="FontSize" Value="11"/>
								</Style>
								<Style TargetType="TextBlock">
									<Setter Property="FontSize" Value="11"/>
								</Style>
							</StackPanel.Resources>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Method Name:" HorizontalAlignment="Right" Margin="10,0"/>
								<TextBox Grid.Column="1" Text="{Binding NewMethodName, UpdateSourceTrigger=PropertyChanged}"/>
							</Grid>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Return Type:" HorizontalAlignment="Right" Margin="10,0"/>
								<TextBox Grid.Column="1" Text="{Binding NewMethodReturnType, UpdateSourceTrigger=PropertyChanged}"/>
							</Grid>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Parameters:" HorizontalAlignment="Right" Margin="10,0"/>
								<TextBox Grid.Column="1" Text="{Binding NewMethodParameters, UpdateSourceTrigger=PropertyChanged}"/>
							</Grid>
							<Grid Height="20">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Repository:" HorizontalAlignment="Right" Margin="10,0" VerticalAlignment="Center"/>
								<ComboBox Grid.Column="1" VerticalAlignment="Center" SelectedItem="{Binding SelectedRepository}">
									<ComboBox.ItemsSource>
										<CompositeCollection>
											<!--<ComboBoxItem Foreground="Gray">-None-</ComboBoxItem>-->
											<CollectionContainer Collection="{Binding Source={StaticResource RepositoryItemsSource}}" />
										</CompositeCollection>
									</ComboBox.ItemsSource>
									<ComboBox.ItemTemplate>
										<DataTemplate>
											<TextBlock Text="{Binding ImplementationClass, Converter={StaticResource SplitPascalCase}}"/>
										</DataTemplate>
									</ComboBox.ItemTemplate>
								</ComboBox>
							</Grid>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Comment:" HorizontalAlignment="Right" Margin="10,0"/>
								<TextBox Grid.Column="1" Text="{Binding NewMethodComment, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" Height="50"/>
							</Grid>
							<Grid Visibility="Collapsed">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Return Comment:" HorizontalAlignment="Right" Margin="10,0"/>
								<TextBox Grid.Column="1" Text="{Binding NewMethodReturnComment, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" Height="50"/>
							</Grid>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="100"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Text="Add Tests:" HorizontalAlignment="Right" Margin="10,0"/>
								<CheckBox Grid.Column="1" IsChecked="{Binding NewMethodAddTests, UpdateSourceTrigger=PropertyChanged}"/>
							</Grid>

						</StackPanel>
					</ScrollViewer>
					<GridSplitter Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="4"/>
					<DataGrid Grid.Row="2" ItemsSource="{Binding SelectedServiceInterface.Methods}" SelectedItem="{Binding SelectedServiceMethod}" HorizontalContentAlignment="Stretch"
							  AutoGenerateColumns="False" 
							  SelectionMode="Single" 
							  CanUserAddRows="True"
							  GridLinesVisibility="Horizontal" 
							  RowEditEnding="OnRowEditEnding"
							  AddingNewItem="OnAddingNewRow"
							  SelectionChanged="OnSelectedMethodChanged"
							  HorizontalGridLinesBrush="#AAA" Margin="4" BorderBrush="LightBlue">
						<DataGrid.Columns>
							<DataGridTextColumn Header="Name" Binding="{Binding Name, UpdateSourceTrigger=PropertyChanged}" FontWeight="Bold" MinWidth="140"/>
							<DataGridTextColumn Header="Type" Binding="{Binding ReturnType, UpdateSourceTrigger=PropertyChanged}" MinWidth="110"/>
							<DataGridTextColumn Header ="Arguments" Binding="{Binding ArgumentSignature, UpdateSourceTrigger=PropertyChanged}" MinWidth="200"/>
						</DataGrid.Columns>
					</DataGrid>
				</Grid>
			</TabItem>
			<TabItem Header="settings">
				<Grid DataContext="{Binding Settings}" Margin="2">
					<Grid.RowDefinitions>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="140"/>
						<ColumnDefinition Width="0"/>
						<ColumnDefinition Width="*"/>
					</Grid.ColumnDefinitions>
					<TextBlock Grid.Row="0" Grid.Column="0" Text="Root Path"/>
					<TextBox Grid.Row="0" Grid.Column="2" Text= "{Binding RootFolder, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="1" Grid.Column="0" Text="Gateway Project"/>
					<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding GatewayProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="2" Grid.Column="0" Text="Host Project"/>
					<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding HostProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="3" Grid.Column="0" Text="Implementation Project"/>
					<TextBox Grid.Row="3" Grid.Column="2" Text="{Binding ImplementationProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="4" Grid.Column="0" Text="Interface Project"/>
					<TextBox Grid.Row="4" Grid.Column="2" Text="{Binding InterfaceProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="5" Grid.Column="0" Text="Repository Project"/>
					<TextBox Grid.Row="5" Grid.Column="2" Text="{Binding RepositoryProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="6" Grid.Column="0" Text="Proxy Project"/>
					<TextBox Grid.Row="6" Grid.Column="2" Text="{Binding ProxyProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="7" Grid.Column="0" Text="Fake Gatway Project"/>
					<TextBox Grid.Row="7" Grid.Column="2" Text="{Binding FakeGatewaysProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="8" Grid.Column="0" Text="Site Solution"/>
					<TextBox Grid.Row="8" Grid.Column="2" Text="{Binding SiteSolution, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="9" Grid.Column="0" Text="Services Solution"/>
					<TextBox Grid.Row="9" Grid.Column="2" Text="{Binding ServicesSolution, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="10" Grid.Column="0" Text="Integration Tests"/>
					<TextBox Grid.Row="10" Grid.Column="2" Text="{Binding ServiceImplementationTestProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="11" Grid.Column="0" Text="Gateway Tests"/>
					<TextBox Grid.Row="11" Grid.Column="2" Text="{Binding GatewayTestProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="12" Grid.Column="0" Text="Controller Tests"/>
					<TextBox Grid.Row="12" Grid.Column="2" Text="{Binding ControllerTestProject, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="13" Grid.Column="0" Text="Test Project #3"/>
					<TextBox Grid.Row="13" Grid.Column="2" Text="{Binding TestProjectNumber3, UpdateSourceTrigger=PropertyChanged}"/>
					<TextBlock Grid.Row="14" Grid.Column="0" Text="Close Undo Context after Add"/>
					<CheckBox Grid.Row="14" Grid.Column="2" IsChecked="{Binding ShouldCloseUndoContext, UpdateSourceTrigger=PropertyChanged}"/>
				</Grid>
			</TabItem>
		</TabControl>
		<GridSplitter Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="4" BorderBrush="#555" BorderThickness="0,0,0,1"/>
		<TabControl Grid.Column="1" Grid.Row="1" Background="{x:Null}"      >
			<TabItem Header="services" Margin="-1,0,1,0">
				<ListBox ItemsSource="{Binding ServiceInterfaces}" SelectedItem="{Binding SelectedServiceInterface}" HorizontalContentAlignment="Stretch">
					<ListBox.ItemTemplate>
						<DataTemplate>
							<Grid Height="25" VerticalAlignment="Center" Background="#ddd" Margin="0,1,1,1" >
								<TextBlock Text="{Binding ImplementationName, Converter={StaticResource SplitPascalCase}}" Margin="5,2,2,2" Foreground="Black" VerticalAlignment="Center" FontSize="11"/>
							</Grid>
						</DataTemplate>
					</ListBox.ItemTemplate>
				</ListBox>
			</TabItem>
			<TabItem Header="methods" Background="{x:Null}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="auto"/>
						<RowDefinition Height="*"/>
					</Grid.RowDefinitions>
					<Border Background="Gray" CornerRadius="3" BorderBrush="Gray" BorderThickness="2" Margin="1,3">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="auto" />
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="auto" />
							</Grid.ColumnDefinitions>
							<TextBlock Text="Search" Foreground="Silver" Background="Transparent" Padding="2,0,2,0" VerticalAlignment="Center" FontSize="10"/>
							<TextBox x:Name="Search" Text="{Binding CurrentSearchTerm, UpdateSourceTrigger=PropertyChanged}" KeyDown="OnFilter" Grid.Column="1" FontSize="10"/>
							<Button Grid.Column="2" Content="X" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="OnFilterClear" Width="15" Padding="0,0,0,2" Background="LightSteelBlue" ToolTip="Clear Filter" FontSize="10"/>
						</Grid>
					</Border>
					<ListBox Grid.Row="1" ItemsSource="{Binding Source={StaticResource MethodItemsSource}}" SelectedItem="{Binding SelectedServiceMethod}" HorizontalContentAlignment="Stretch">
						<ListBox.ItemTemplate>
							<DataTemplate>
								<Grid Height="25" VerticalAlignment="Center" Background="#ddd" Margin="0,1,1,1">
									<Grid.RowDefinitions>
										<RowDefinition Height="auto"/>
										<RowDefinition Height="*"/>
									</Grid.RowDefinitions>
									<TextBlock Grid.Row="1" Text="{Binding Name}" Margin="5,2,2,2" Foreground="Black" VerticalAlignment="Center" FontSize="11"/>
								</Grid>
							</DataTemplate>
						</ListBox.ItemTemplate>
					</ListBox>
				</Grid>
			</TabItem>
		</TabControl>
		<StatusBar Grid.Row="2" Grid.ColumnSpan="2" Height="18" Margin="0,0,10,0" Background="White">
			<StatusBar.Resources>
				<Style TargetType="TextBlock">
					<Setter Property="FontSize" Value="10"/>
				</Style>
			</StatusBar.Resources>
			<StatusBarItem Padding="0" Background="White" HorizontalAlignment="Left" Margin="2,0,5,0">
				<ProgressBar IsIndeterminate="True" Width="100" Height="10" Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" Foreground="Purple"/>
			</StatusBarItem>
			<StatusBarItem Padding="0" Background="White" HorizontalAlignment="Left" Margin="2,0,0,0">
				<TextBlock Text="{Binding Status}"/>
			</StatusBarItem>
			<StatusBarItem Padding="0" Background="White" HorizontalAlignment="Right">
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="{Binding SelectedServiceInterface.Name}" TextAlignment="Right" Margin="0,0,10,0"/>
					<Image Source="{Binding SvcImplementationProject, Converter={StaticResource BoolToRedOrGreenImage}}" ToolTip="Service Implementation" Margin="2"/>
					<Image Source="{Binding SvcInterfaceProject, Converter={StaticResource BoolToRedOrGreenImage}}" ToolTip="Service Interfaces" Margin="2"/>
					<Image Source="{Binding AppGatewayProject, Converter={StaticResource BoolToRedOrGreenImage}}" ToolTip="Gateway and Proxies" Margin="2"/>
					<Image Source="{Binding AppGatewayProject, Converter={StaticResource BoolToRedOrGreenImage}}" ToolTip="Repositories" Margin="2"/>
					<Image Source="{Binding ServiceSolution, Converter={StaticResource ObjectRefToRedOrGreenImage}}" ToolTip="Service Solution DTE" Margin="10,2,0,2"/>
					<Image Source="{Binding SiteSolution, Converter={StaticResource ObjectRefToRedOrGreenImage}}" ToolTip="Site Solution DTE" Margin="2"/>
				</StackPanel>
			</StatusBarItem>
		</StatusBar>
	</Grid>
</UserControl>
